import React, { contextTypes } from 'react';
import Sign from '../components/sign';
import { connect } from 'react-redux';
import { hashHistory } from 'react-router'

class SignPage extends React.Component {

    constructor(props) {
        super(props);
        this.handleSubmit = this.handleSubmit.bind(this);
        this.checkUsername = this.checkUsername.bind(this);
        this.checkPassword = this.checkPassword.bind(this);
    }

    handleSubmit(values) {
        sessionStorage.isLogin = 'true';
        hashHistory.push('/');
        console.log(values);
    }

    checkUsername(rule, value, callback) {
        // if (!value) {
        //     callback();
        // } else {
        //     callback([new Error('抱歉，该用户名已被占用。')]);
        // }
        callback();
    }

    checkPassword(rule, value, callback) {
        // if (!value) {
        //     callback();
        // } else {
        //     callback([new Error('抱歉，该用户名已被占用。')]);
        // }
        callback();
    }

    render() {
        return (
            <Sign handleSubmit={this.handleSubmit} checkUsername={this.checkUsername} checkPassword={this.checkPassword}/>
        );
    }
}

function mapStateToProps(state) {
}

// export default connect(mapStateToProps, {  })(SignPage);
export default SignPage;